package com.rdc.qingkou.widget;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;


/**
 * Created by asus on 2017/7/24.
 */

public class TypeFaceTextView extends AppCompatTextView {
    public TypeFaceTextView(Context context) {
        super(context);

        //得到AssetManager
        AssetManager mgr = context.getAssets();
//根据路径得到Typeface
        Typeface tf = Typeface.createFromAsset(mgr, "fonts/Kaiti.ttf");
//设置字体
        this.setTypeface(tf);
    }

    public TypeFaceTextView(Context context, AttributeSet attrs) {
        super(context, attrs);

        //得到AssetManager
        AssetManager mgr = context.getAssets();
//根据路径得到Typeface
        Typeface tf = Typeface.createFromAsset(mgr, "fonts/Kaiti.ttf");
//设置字体
        this.setTypeface(tf);
    }

    public TypeFaceTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        //得到AssetManager
        AssetManager mgr = context.getAssets();
//根据路径得到Typeface
        Typeface tf = Typeface.createFromAsset(mgr, "fonts/Kaiti.ttf");
//设置字体
        this.setTypeface(tf);
    }
}
